cmake_minimum_required(VERSION 3.2)
project(flashpp)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_BUILD_TYPE Debug)

set(LIBRARY_NAME
    flashpp
)

find_package(Boost 1.54.0 REQUIRED COMPONENTS log thread system)
find_package(folly REQUIRED)
find_package(Gflags REQUIRED)
find_package(range-v3 REQUIRED)

include_directories(
  ${CMAKE_SOURCE_DIR}/src
  ${Boost_INCLUDE_DIRS}
  ${FOLLY_INCLUDE_DIR}
  # ${CMAKE_SOURCE_DIR}/lib/nanobdd/include
)

add_library(${LIBRARY_NAME}
  src/common/Device.cpp
  src/common/HeaderSpace.cpp
  src/common/EventBase.cpp
  src/common/Network.cpp
  src/flashpp/Flashpp.cpp
  src/expander/Expander.cpp
  src/model-updater/ModelUpdater.cpp
  src/normalizer/Normalizer.cpp
  src/pipeline/ActionAggregator.cpp
)

target_link_libraries(${LIBRARY_NAME}
  ${Boost_LIBRARIES}
  ${FOLLY_LIBRARIES}
  bdd
  yaml-cpp
  # range-v3
  sylvan
  nanobdd
)

target_include_directories(${LIBRARY_NAME} PRIVATE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/${LIBRARY_NAME}>
    $<INSTALL_INTERFACE:include/${LIBRARY_NAME}>
)

target_include_directories(${LIBRARY_NAME} PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)

# add_subdirectory("lib/nanobdd/")

add_executable(flashpp_bin
  src/Main.cpp
)

target_link_libraries(flashpp_bin
  ${LIBRARY_NAME}
  ${Boost_LIBRARIES}
  ${FOLLY_LIBRARIES}
  nanobdd
  yaml-cpp
  jemalloc
  tbb
)